/* NoX (NoC Simulator)
 *
 * Dept. of Computer Science & Engineering, Pennsylvania State University.
 * All Rights Reserved.
 *  
 * 1. License     
 * NoX is distributed free of charge for academic, educational, noncommercial 
 * research purposes as long as this notice in its entirety is preserved in
 * every file included in this package.
 * All commercial use of this program requires separate licence. Contact the
 * author for details.
 * 
 * 2. All the publications that used the simulation results generated by the 
 * NoX should notify the author of the publication information and put 
 * following reference.
 *
 *  http://www.cse.psu.edu/~dpark/nox/
 * 
 * 3. Modification of the source code is permitted and encouraged as long as 
 * it follows the terms described in this copyright notice.
 *
 * 4. The author is not responsible for any problems caused by possible errors
 * of the NoX package. Therefore, users should verify the simulation result
 * before using it in their publication.
 *
 * Dept. of Computer Science & Engineering, Pennsylvania State University.
 * Contact: dpark@cse.psu.edu 
 * 
 * 6. If problems are found with the NoX package, please send an email to the
 * author for discussion and correction.

 */

/* Update History
 *
 * Jan. 31, 2006  Version 1.0 released by Dongkook Park 
 *
 */


#ifndef MAIN_H
#define MAIN_H

#include "stdio.h"
#include "router.h"
/*
#ifdef USE_MYSQL
#include "mysql.h"
#endif
*/

#define VALID    0
#define INVALID  1
#define YES	 0
#define NO	 1

//#define MSG_TO_INJECT 400000 // 40000
//#define WARMUP_MSG      1000 // 10000 
//#define MSG_TO_EJECT  399000 // 20000

// Cycle times for 2-stage and 3-stage architecture.
//#define CYCLE_TIME2   5.0 // in ns(nano-seconds). 200MHz clock frequency. (10^9) / (200*10^6) = 5.0
//#define CYCLE_TIME3   2.0 // in ns(nano-seconds). 500MHz clock frequency. (10^9) / (500*10^6) = 2.0

#define CYCLE_TIME2   500.0 // in pico-seconds
#define CYCLE_TIME3   500.0 // in pico-seconds

// Routing algorithms
#define DT              0 // Deterministic routing... (X-Y routing) 
#define AD              1 // Fully Adaptive routing...
#define PA              2 // Proximity Aware Fault Tolerant routing...
#define SF              3 // Simple Fault Tolerant routing...
#define WF              4 // West-First routing.

// Topology
#define MESH            0
#define TORUS           1
#define BFLY            2
#define BUS             3
#define XBAR            4
#define FTREE           5 
#define TTREE           6

// Error Check & Retransmission
#define FEC             0 // Forward Error Correction
#define HFEC            1 // Head-error checking FEC
#define E2E             2 // End-to-End Retransmission
#define HE2E            3 // Head-error checking E2E
#define HBH             4 // Hob-by-Hop retransmission
#define NONE            5 

// Traffic Pattern (for detail, see app.c)
#define NR              0 // Normal Random
#define TP              1 // Transpose
#define TN              2 // Tornado
#define BC              3 // Bit-Complement
#define NB              4 // Nearest-Neighbor
#define HT              5 // Nearest-Neighbor
#define LC              6 // Non-Uniform
 
// Input Traffic
#define UNIFORM         0 // Uniform input traffic
#define MULTIMEDIA      1 // Multimedia input traffic
#define SSIMILAR        2 // Self-Similar input traffic

// Error type
#define ERROR_NONE      0 // No error
#define ERROR_LINK      1 // Link error
#define ERROR_ROUTING   2 // Routing Logic Error
#define ERROR_SW_ARB    4 // Switch Arbiter Error
void sim_init(int argc, char **argv);  // defined in sim_init.c
void node_init();                      // defined in node_init.c
void update_mbox_count();
void update_vc_info_stat();
void update_is_ready_flag();
void update_xbar_reserve_status();
void update_link_usage();
void power_init(int tech, int flit_width, int pc);
bool sort_pos (sort_t a, sort_t b);
bool sort_val (sort_t a, sort_t b);
void print_vc_state(int n);
void update_interference_cycles();
#endif
